define(["jquery-1.8.2.js", "mdialog_module.js"], function(require, exports, module) {
	var M = require('mdialog_module');
	//弹窗显示速度ms
	var show_speed = 300;
	var loadfail = "../images/icons/loadfail.png";
	var loadicon = "../images/icons/qq.png";
	var payUrl = "http://www.tangjingting.com/apiModule/wxCore/toPay?paymentType=1&payType=3&";
	//检测是否ie
	loadBackground(true);

	if(isIE()) {
		$("body").append(" <div class='loader'> <img style='width: 200px;' src='../images/loadimg.gif'/> </div>");
	} else {
		$("body").append(" <div class='loader'>  <div class='dot'></div>  <div class='dot'></div> <div class='dot'></div> <div class='dot'></div> <div class='dot'></div></div>");
	}

	function loadOpt(open) {
		if(open) {
			loadBackground(true);
			$(".loader").show();
		} else {
			$(".loader").hide();
			loadBackground(false);
		}
	}

	function isIE() {
		if(!!window.ActiveXObject || "ActiveXObject" in window)
			return true;
		else
			return false;
	}

	function translate_time(str, reallyDo, replaceWith) { //转换时间
		var e = new RegExp(reallyDo, "g");
		words = str.replace(e, replaceWith);
		return words;
	}

	function paging_handle(page, method) {
		//分页导航数据处理
		totalPage = page.totalPage;
		$("#paging .page").empty();
		var start_count = 0;
		try {
			if(curPage >= 11) {
				start_count = curPage - 4;
			}
		} catch(e) {}
		for(var i = start_count; i < totalPage; i++) {
			if(i + 1 == curPage) {
				$("#paging .page").append("<div style='color:white;border-color:white;background-color:#DC3F44'>" + (i + 1) + "</div>");
			} else {
				$("#paging .page").append("<div>" + (i + 1) + "</div>");
			}
		}
		$(".Record>span:nth-child(1)").text("共" + page.totalItem + "条记录");
		$(".Record>span:nth-child(2)").text(curPage + "/" + page.totalPage);
		$("#paging .goto_page>input").val(curPage);
		//分页导航数据处理完毕
		//处理单击事件
		$(".next_page").unbind("click").click(function() {
			if(!page.nextPage) {
				alert("已经是最后一页了!")
				return false;
			}
			curPage++;
			method();
		});
		$(".up_page").unbind("click").click(function() {
			if(curPage == 1) {
				alert("已经是第一页了!");
				return false;
			}
			curPage--;
			method();
		});
		$("#paging .page>div").unbind("click").click(function() {
			curPage = $(this).text();
			method();
		});
		$("#paging .goto").unbind("click").click(function() {
			try {
				var index = $("#paging .goto_page>input").val();
				if(index <= totalPage && index > 0 && !/^[+-]?[1-9]?[0-9]*\.[0-9]*$/.test(index)) {
					curPage = $("#paging .goto_page>input").val();
					method();
				} else {
					alert("请输入正确的页码！");
				}
			} catch(e) {
				alert("请输入正确的页码！");
			}
		});
		//单机事件绑定完毕
	}

	function browser() {
		var ver = "";
		try {
			var browser = navigator.appName
			var b_version = navigator.appVersion
			var version = b_version.split(";");
			var trim_Version = version[1].replace(/[ ]/g, "");
			if(browser == "Microsoft Internet Explorer" && trim_Version == "MSIE8.0") {
				ver = "MSIE8.0";
			}
			if(browser == "Microsoft Internet Explorer" && trim_Version == "MSIE9.0") {
				ver = "MSIE9.0";
			}
		} catch(e) {}
		return ver;
	}

	function placeholder_imitate() {
		if(isIE()) {
			placeholder($("input"));
			return false;
		}
	}

	function placeholder(input) {
		var supportPlaceholder = 'placeholder' in document.createElement('input');
		input.each(function(i) {
			if(!supportPlaceholder && ($(this).attr("type") == "text" || $(this).attr("type") == "password")) {
				var text = $(this).attr("placeholder");
				if(text == undefined) {
					return true;
				}
				if($(this).attr("type") == "password") {
					$(this).val("");
					$(this).hide();
					var textinput = $("<input type='text' value='密码' style='color:#999' />");
					if($(this).parent().find("input").length == 2) {
						$(this).parent().find("input").eq(1).remove();
					}
					$(this).parent().append(textinput);
					textinput.off("click").on("click", function() {
						$(this).parent().find("input").eq(0).show().focus();
						$(this).hide();
					});
					textinput.off("focus").on("focus", function() {
						$(this).parent().find("input").eq(0).show().focus();
						$(this).hide();
					});
				} else {
					$(this).val(text);
				}
				$(this).css("color", "#999");
				$(this).off("focus").on("focus", function() {
					if($.trim($(this).val()) == $(this).attr("placeholder")) {
						$(this).val("");
						$(this).css("color", "#000000");
					}
				});
				$(this).off("blur").on("blur", function() {
					if($.trim($(this).val()) == "") {
						if($(this).attr("type") == "password") {
							$(this).parent().find("input").eq(1).show();
							$(this).hide();
						} else {
							$(this).val($(this).attr("placeholder"));
							$(this).css("color", "#999");
						}
					}
				});
			}
		});
	}

	function progress(inputList) {
		/*$(inputList).each(function(){
			var progress = $(this).Progress({
				percent: 20,
				width: 180,
				height: 40,
				fontSize: 16
			});
			setTimeout(function(){
				progress.percent(90);
			}, 4000);
		})*/
	}

	//补0操作  
	function getzf(num) {
		if(parseInt(num) < 10) {
			num = '0' + num;
		}
		return num;
	}
	//传入数组或者字符串获取图片
	function getImg(objs) {
		var result = new Array();
		try {
			$(objs).each(function() {
				if(this == "") {
					return true;
				}
				result.push(this);
			});

		} catch(e) {
			result = [];
		}
		try {
			$(objs.split(",")).each(function() {
				if(this == "") {
					return true;
				}
				result.push(this);
			});
		} catch(e) {
			result = [];
		}
		return result;
	}

	//获取上一个页面名称
	function up_view() {
		var upUrl = document.referrer.substring(document.referrer.lastIndexOf("/") + 1);
		if(upUrl == "") {
			return "";
		}
		if(upUrl.substring(upUrl.length - 4) != "html") {
			return upUrl.substring(0, upUrl.indexOf("?"));
		} else {
			return upUrl;
		}
	}

	function getNum(data) { //比较时间差
		var timestamp = Date.parse(new Date()); //当前时间戳
		var oldtimestamp = Date.parse(data); //固定日期的时间戳
		var newtimestamp = oldtimestamp - timestamp; //间隔的时间毫秒
		var day = parseInt(newtimestamp / (24 * 60 * 60 * 1000)) + 1; //除以一天的毫秒数，得出间隔天数
		if(day < 0) {
			day = 0;
		}
		return day;
	}
	//获取当前页面名称
	function this_view() {
		var upUrl = location.href.substring((location.href).lastIndexOf("/") + 1);
		if(upUrl == "") {
			return "";
		}
		if(upUrl.substring(upUrl.length - 4) != "html") {
			return upUrl.substring(0, upUrl.indexOf("?"));
		} else {
			return upUrl;
		}
	}
	var temp_top = new Object();
	//鼠标悬浮导航栏事件
	function hover_event() {
		$("#top>div>p").unbind("mouseover").bind("mouseover", function() {
			var index = $(this).parent().index();
			if(index == 0) {
				return false;
			}
			$("#top>div").find(".class_two").hide();
			$("#top span").hide();
			$("#top>div").css("background-color", "white");
			$("#top>div").css("color", "black");
			$("#top>div").eq(index).css("background-color", "#e13c44");
			$("#top>div").eq(index).css("color", "white");
			$(this).find("span").show();
			var class_two = $(this).parent().find(".class_two").show();
			$(class_two).find("p").click(function(e) {
				e.stopPropagation();
				var id = $(this).attr("id");
				loadOpt(true);
				ajaxget("/news/newsByTid/" + id, {}, function(json) {
					/*console.log(json);
					return;*/
					loadOpt(false);
					if(json.success) {
						var news = json.models.newsDetailList;
						if(news.length == 1) {
							if(news[0].contentType == 1) {
								location.href = news[0].content;
								return false;
							} else {
								location.href = "Policy_details.html?id=" + news[0].id + "&index=" + getParam("index");
								return false;
							}
						} else {
							location.href = "policy_list.html?&id=" + id;
						}
					} else {
						M.toast(false, json.errorMsg);
					}
				});
			});
		});
		$("#top >div").unbind("mouseleave").bind("mouseleave", function() {
			$("#top>div").css("background-color", "white");
			$("#top>div").css("color", "black");
			$("#top span").hide();
			$("#top>div").find("div").hide();
		});
	}


	//举报和投诉窗口
	function loadComplaint(a, object) {
		if(a) {
			if($("#Complaints_and_reports_view").length == 0) {
				var c = "<div style='display:none' id='Complaints_and_reports_view'><div class='close'><img src='../images/icons/icon_guangbi.png'/></div><div class='Complaints_and_reports_text'><div>投诉类容：</div><textarea name=''rows=''cols=''value='打算的撒的'></textarea></div><div class='voucher'><div>投诉凭证：</div><div><img src='../images/icons/zhengjiantupian.png'/></div><div class='upload'>上传</div></div><input style='display:none;' name='temp_upload' type='file' id='temp_upload' /><div class='phone'><div>联系方式：</div><div><input type=''placeholder='非必填项'/></div></div><div class='button'><div></div><div><div>确定</div><div>取消</div></div></div></div>";
				$("body").append(c);
				var temp_upload = "<input style='display:block;' name='temp_upload' type='file' id='temp_upload' />"
				//				$("body").append(temp_upload);
				var IMG = require('imgUpload_module');
				if(isIE()) {
					$(".upload").hide();
					$("#temp_upload").show();
					IMG.ajaxFileUpload("temp_upload", function(result) {
						if(result.success) {
							var url = result.models.url;
							$("#Complaints_and_reports_view .voucher img").attr("upload_img", url + "");
							$("#Complaints_and_reports_view .voucher img").attr("src", url + "");
							$("#dynamic_img").replaceWith("<input type='file'  name= 'temp_upload' id='temp_upload'>");
							registerfj();
						}
					});
				} else {
					IMG.uploadImg({
						'obj': $('#temp_upload'),
						'success': function(json, obj) {
							if(json.state == "SUCCESS") {
								$("#Complaints_and_reports_view .voucher img").attr("upload_img", json.url + "");
								$("#Complaints_and_reports_view .voucher img").attr("src", json.url + "");
							} else {
								M.toast(false, "上传失败！");
							}
						},
						'error': function(msg) {
							M.error(msg);
						}
					});
				}

				$("#Complaints_and_reports_view .voucher .upload").click(function() {
					$("#temp_upload").click();
				});
				placeholder_imitate();
				var w = $(".Complaints_and_reports_text>div").width();
				$("#Complaints_and_reports_view .button>div:first-child").width(w);
				$("#Complaints_and_reports_view .close").click(function() {
					loadComplaint(false, {});
				});
				$("#Complaints_and_reports_view .button>div:last-child>div").click(function() {
					if($(this).text() == "取消") {
						loadComplaint(false, {});
					} else {
						//调用接口
						var content = $(".Complaints_and_reports_text textarea").val();
						var images = $("#Complaints_and_reports_view .voucher img").attr("upload_img");
						if(content == "" || content == null) {
							alert("请输入投诉内容!");
							return false;
						}
						if(images == "" || images == null) {
							alert("请上传一张凭证!");
							return false;
						}
						var connect = $("#Complaints_and_reports_view .phone>div:last-child>input").val();
						var ctype = 2;
						if(object.text == "举报") {
							ctype = 1;
						}
						var params = {
							smId: object.message.id,
							title: object.message.title,
							ctype: ctype,
							content: content,
							images: images,
							connect: connect
						};
						ajax("/complaints/add", params, function(json) {
							loadOpt(false);
							if(json.success) {
								alert(object.text + "成功!");
								$("#Complaints_and_reports_view").hide();
							} else {
								alert(json.errorMsg);
							}
						});
					}
				});
			}
			loadBackground(true);
			if(isIE()) {
				$("#temp_upload").show();
			}
			$(".Complaints_and_reports_text>div").text(object.text + "内容：");
			$("#Complaints_and_reports_view").show(show_speed);
		} else {
			loadBackground(false);
			$("#temp_upload").hide();
			$("#Complaints_and_reports_view").hide();
		}
	}
	//加载单位详情
	function loadUnit_view(a, object) {
		if(a) {
			if($("#Unit_details").length == 0) {
				$("body").append("<div style='display:none' id='Unit_details'><div class='close'><img src='../images/icons/icon_guangbi.png'></div><div class='Unit_details_info' id=''><div class='Unit_name'><span>单位名称</span> <img src='../images/icons/fhbbzz.png'><span>符合帮扶资质</span></div><div class='Unit_phone'><img src='../images/icons/phone.png'><span>136666666666</span></div><div class='Unit_email'><img src='../images/icons/icon_youjian.png'> <span>未知</span></div><div class='Unit_address'><img src='../images/icons/icon_weizhi.png'> <span>未知</span></div><div class='Unit_user'><span>责任人：</span> <span>张三</span></div><div class='Unit_code'><span>证件号码：</span> <span>66666666666666</span></div><div class='Unit_remark'><span>备&nbsp;注：</span><span>我tm还能说什么...我tm还能说什么...我tm还能说什么...</span></div></div></div>");
				placeholder_imitate();
				$("#Unit_details .close").click(function() {
					loadUnit_view(false);
				});
			}
			ajaxget("/person/detailByUid/" + object.id, {}, function(json) {
				if(json.success) {
					try {
						var personVO = json.models.personVO;
						$("#Unit_details .Unit_name>span:nth-child(1)").text(personVO.name); //单位名称
						$("#Unit_details .Unit_phone>span").text(formPhone(personVO.mobile)); //手机号码
						$("#Unit_details .Unit_email>span").text(formPhone(personVO.email)); //邮箱
						$("#Unit_details .Unit_address>span").text(personVO.address); //地址
						$("#Unit_details .Unit_user>span:last-child").text(personVO.name); //责任人
						$("#Unit_details .Unit_code>span:last-child").text(formPhone(personVO.cardCode)); //证件号
						$("#Unit_details .Unit_remark>span:last-child").text(personVO.remark); //备注
						loadBackground(true);
						$("#Unit_details").show(show_speed);
					} catch(e) {
						alert("用户信息不完整!");
						loadBackground(false);
						$("#Unit_details").hide();
					}
				} else {
					M.toast(false, json.errorMsg);
				}
			});

		} else {
			loadBackground(false);
			$("#Unit_details").hide();
		}
	}
	//加载负责人详情
	function loadduty_view(a, object) {
		if(a) {
			if($("#duty_details").length == 0) {
				$("body").append("<div style='display:none' id='duty_details'><div class='close'><img src='../images/icons/icon_guangbi.png'></div><div class='duty_details_info' id=''><div class='duty_name'><span>单位名称</span> <img src='../images/icons/fhbbzz.png'><span>符合监管资质</span></div><div class='duty_phone'><img src='../images/icons/phone.png'><span>136666666666</span></div><div class='duty_email'><img src='../images/icons/icon_youjian.png'> <span>151265656@163.com</span></div><div class='duty_user'><span>责任人：</span> <span>张三</span></div><div class='duty_code'><span>证件号码：</span> <span>4499999******666666</span></div><div class='duty_remark'><span>备&nbsp;&nbsp;注：</span><span>我tm还能说什么...我tm还能说什么...我tm还能说什么...</span></div></div></div>");
				$("#duty_details .close").click(function() {
					loadduty_view(false);
				});
			}
			ajaxget("/responsible/get/" + object.id, {}, function(json) {
				if(json.success) {
					try {
						var responsibleVO = json.models.responsibleVO;
						$("#duty_details .duty_name>span:first-child").text(responsibleVO.name);
						$("#duty_details .duty_phone span").text(formPhone(responsibleVO.phone));
						$("#duty_details .duty_remark>span:last-child").text(responsibleVO.remark);
						if(responsibleVO.email==null){
							responsibleVO.email=''
						}
						$("#duty_details .duty_email span").text(formPhone(responsibleVO.email));
						$("#duty_details .duty_code>span:last-child").text(formPhone(responsibleVO.cardCode));
						$("#duty_details .duty_user>span:last-child").text(responsibleVO.name);
						loadBackground(true);
						$("#duty_details").show(show_speed);
					} catch(e) {
						alert("信息不完整!");
						loadBackground(false);
						$("#duty_details").hide();

					}
				} else {
					M.toast(false, json.errorMsg);
				}
			});
			loadBackground(true);
			$("#duty_details").show(show_speed);
		} else {
			loadBackground(false);
			$("#duty_details").hide();
		}
	}
	//加载贫困户信息
	function laodPoor_view(a, object) {
		if(a) {
			if($("#poor").length == 0) {
				$("body").append("<div style='display:none' id='poor'><script type='text/javascript' src='http://api.html5media.info/1.1.6/html5media.min.js'></script><div class='close'><img src='../images/icons/icon_guangbi.png'></div><div class='poor_info' id='p'><div class='poor_name'><span>户主姓名</span><span><img src='../images/icons/fhbbzz.png'>符合扶贫资质</span></div><div class='poor_phone'><img src='../images/icons/phone.png'><span>1366666666</span></div><div class='poor_address'><img src='../images/icons/icon_weizhi.png'><span>召唤师峡谷666666</span></div></div><div class='poor_count'><span>家庭成员</span> <span>4人</span></div><div class='Member_of_family_list'><table border='1' cellspacing='0' cellpadding='0'><tr class='family_list_title'><td>关系</td><td>姓名</td><td>年龄</td><td>性别</td><td>备注</td></tr><tr><td>父亲</td><td>张三</td><td>66</td><td>女</td><td>没有备注哦</td></tr><tr><td>父亲</td><td>张三</td><td>66</td><td>女</td><td>没有备注哦</td></tr></table></div><div class='poor_eason'><div><span>平均年收入：</span><span>1000元以下</span></div><div><span>是否低保：</span><span>是</span></div><div><span>对帮扶的需求：</span><span>因为爱情所以贫困因为爱情所以贫困因为爱情所以贫困因为爱情所以贫困</span></div><div><span>致贫原因：</span><span>因为爱情所以贫困因为爱情所以贫困因为爱情所以贫困因为爱情所以贫困</span></div>  <div><span>贫困现状：</span><span>没有备注哦</span></div>    <div><span>备注：</span><span>没有备注哦</span></div>    </div><div class='help_log_title'>帮扶记录</div><div class='help_log_list'><table border='1' cellspacing='0' cellpadding='0'><tr class='help_log_list_title'><td>帮扶人/单位</td><td>帮扶形式</td><td>捐款金额</td><td>物资细致</td><td>时间</td><td>状态</td></tr><tr><td>掌商科技</td><td>冲QB</td><td>张三</td><td>66</td><td>2016-6-6</td><td>进行中</td></tr></table></div><p class='other_html'></p><div class='help_he'>帮助他</div></div>");
				$(".help_log_list,.help_log_title").hide(); //隐藏帮扶记录，暂时不做
				$("#poor .close").click(function() {
					laodPoor_view(false, {});
				});
				$("#poor .help_he").click(function() {
					laodPoor_view(false, {});
					var user = checkLogin();
					if(user.state != 1) {
						alert("请先登录!");
						loadLogin(true);
					} else {
						 if(user.info.typ == 0) {
							alert("您还不是帮扶队员，请前往申请!");
							location.href = "../html/apply.html";
							return false;
						} else {
							window.open("help_entrance.html?poor_id=" + $(this).attr("id"));
						}
					}
				});
			}
			loadOpt(true);
			ajaxget("/poverty/detail/" + object.id, {}, function(json) {
				loadOpt(false);
				if(json.success) {
					try {
						var povertyObjVO = json.models.povertyObjVO;
						$("#poor .poor_name >span:first-child").text(povertyObjVO.name);
						var phone = formPhone(povertyObjVO.connect);
						var user = checkLogin();
						if(user.state == 1 && user.info.personVO.status == 2) {
							phone = povertyObjVO.connect;
						}
						$("#poor .other_html").html(povertyObjVO.intro);
						$("#poor .other_html p img").css('width','100%');
						$("#poor .other_html video").css('object-fit', 'fill');
						$("#poor .poor_phone>span").text(phone);
						$("#poor .poor_address>span").text(povertyObjVO.address);
						$("#poor .poor_count>span:nth-child(2)").text(povertyObjVO.povertyObjPersonList.length + "人");
						$("#poor .Member_of_family_list table").empty();
						$("#poor .Member_of_family_list table").append("<tr class='family_list_title'><td>关系</td><td>姓名</td><td>年龄</td><td>性别</td><td>备注</td></tr>");
						$("#poor .help_he").attr("id", object.id);
						$(povertyObjVO.povertyObjPersonList).each(function() {
							var sex = "未填写"
							if(this.sex == 1) {
								sex = "女";
							} else if(this.sex == 2) {
								sex = "男";
							}
							$("#poor .Member_of_family_list table").append("<tr><td>" + this.relation + "</td><td>" + this.name.substring(0, 1) + "***" + "</td><td>" + this.age + "</td><td>" + (sex) + "</td><td>" + this.remark + "</td></tr>");
						});
						$("#poor .poor_eason>div:nth-child(1)>span:nth-child(2)").text(povertyObjVO.yearAmount + "元");
						$("#poor .poor_eason>div:nth-child(2)>span:nth-child(2)").text(povertyObjVO.low == 0 ? "否" : "是");
						$("#poor .poor_eason>div:nth-child(3)>span:nth-child(2)").text(povertyObjVO.requirement);
						$("#poor .poor_eason>div:nth-child(4)>span:nth-child(2)").text(povertyObjVO.reason);
						$("#poor .poor_eason>div:nth-child(5)>span:nth-child(2)").text(povertyObjVO.currentReason);

						$("#poor .poor_eason>div:nth-child(6)>span:nth-child(2)").text(povertyObjVO.remark);
						loadBackground(true);
						$("#poor").show(show_speed);
					} catch(e) {
						alert("信息不完整!");
						loadBackground(false);
						$("#poor").hide();
					}
				} else {
					M.toast(false, json.errorMsg);
				}
			});
		} else {
			loadBackground(false);
			$("#poor").hide();
		}
	}

	function loadBackground(a) {
		if(a) {
			if($("#background").length == 0) {
				$("body").append("<div id='background'></div>");
			}
			$("#background").show();
			$("#background").css("opacity", "0.5");
		} else {
			$("#background").hide();
		}
	}
	//登录窗口控制
	function loadLogin(a, show_close) {
		if(a) {
			if($("#login").length == 0) {
				var style = "style='display:block'";
				if(show_close != undefined) {
					style = "style='display:none'";
				}
				$("body").append("<div style='display:none' id='login'><div>登录</div><div " + style + " class='close'><img src='../images/icons/icon_guangbi.png'></div><div class='l_phone'><input type='text' placeholder='手机号码'></div><div class='l_pwd'><input type='password' placeholder='密码'></div><div class='remember'><input class='checkbox' type='checkbox'><span>记住密码</span><span class='forget'>忘记密码?</span></div><div class='login_btn'><span>登录</span> <span style='margin-left: 30px'>没有账号?</span> <span class='reg' style='margin-left: 0px'>快速注册</span></div></div>");
				placeholder_imitate();
				if(readCookie("password") != "") {
					$(".l_pwd input").val(readCookie("password"));
				}
				if(readCookie("phone") != "") {
					$(".l_phone input").val(readCookie("phone"));
				}
				$("#login .close").click(function() {
					loadLogin(false);
				});
				$("#login .reg").click(function() {
					loadLogin(false);
					loadReg(true, show_close);
				});
				$("#login .forget").click(function() {
					loadLogin(false);
					loadForgetPwd(a, show_close);
				});
				$(".login_btn>span:nth-child(1)").click(function() {
					var l_phone = $(".l_phone>input").val();
					var l_pwd = $(".l_pwd>input").val();
					if($(".remember input").attr("checked")) {
						writeCookie('password', l_pwd, 7 * 24 * 3600 * 1000);
						writeCookie('phone', l_phone, 7 * 24 * 3600 * 1000);
					} else {
						writeCookie('password', "", 1);
						writeCookie('phone', "", 1);
					}
					if(l_phone == "" || l_pwd == "") {
						alert("请填写完整信息");
						return false;
					}
					var params = {
						username: l_phone,
						password: l_pwd,
						"typ": "0"
					};
					ajax("/user/login", params, function(json) {
						if(!json.success) {
							M.toast(false, json.errorMsg);
							return false;
						} else {
							var userVO = new Object();
							userVO.info = json.models.userVO;
							userVO.loginInfo = params;
							//console.log(json);
							/*writeCookie('fp_user', JSON.stringify(userVO), 7 * 24 * 3600 * 1000); //登录成功写cookice*/
							setCookie('fp_user', JSON.stringify(userVO), 7);
							/*if(userVO.info.personVO.status == 0) {
								//console.log(123);
								alert("您还不是帮扶队员，请前往申请!");
								window.location.href = "apply.html";
								return;
							}*/
							location.reload();

							/*if(userVO.info.typ == 0) {
								if(userVO.info.personVO.status == 0) {
									alert("您还不是帮扶队员，请前往申请!");
									location.href = "../html/apply.html";
								} else if(userVO.info.personVO.status == 1) {
									//alert("您的资料正在审核中!")
									location.href = "../html/wait_review.html";
								} else {
									location.reload();
								}
							} else if(true) {
								history.back();
							}
							location.reload();*/
						}
					});
				});
			}
			loadBackground(true);
			$("#login").show(show_speed);
		} else {
			$("#login").hide();
			loadBackground(false);
		}
	}

	function loadReg(a, show_close) {
		var reg = "";
		if(a) {
			var style = "style='display:block'";
			if(show_close != undefined) {
				style = "style='display:none'";
			}
			if($("#reg").length == 0) {
				$("body").append("<div id='reg'><div>账户注册</div><div " + style + " class='r_close'><img src='../images/icons/icon_guangbi.png'></div><div class='r_phone'><input type='text' placeholder='手机号码'></div><div class='r_code'><div><input type='text' placeholder='验证码'></div><div class='get_code'>获取验证码</div></div><div class='r_pwd'><input type='password' placeholder='密码'></div><div class='r_pwdagin'><input type='password' placeholder='确认密码'></div><div class='remember'><input class='checkbox' type='checkbox'><span><a style='text-decoration: none' href='../html/agreement.html' target='_blank'>我已阅读并同意《平江县社会扶贫平台》</a></span></div><div class='reg_btn'><span>注册</span> <span style='margin-left: 30px'>已有账号,</span> <span class='gologin'>立即登录</span></div></div>");
				placeholder_imitate();
				$("#reg .r_close").click(function() {
					loadReg(false);
				});
				$("#reg .get_code").click(function() {
					var r_phone = $("#reg .r_phone>input").val();
					if(!(/^1[3|4|5|7|8]\d{9}$/.test(r_phone))) {
						alert("手机号码格式错误");
						return;
					}
					$("#reg .get_code").attr("phone", r_phone);
					sendCode($("#reg .get_code"), 80, {
						A: "{color:'white'}",
						B: "{color:'white'}"
					});
				});
				$("#reg .reg_btn>span:nth-child(1)").click(function() {
					var phone = $("#reg .r_phone>input").val();
					var password = $("#reg .r_pwd >input").val();
					var passwordAgin = $("#reg .r_pwdagin  input").val();
					var code = $("#reg .r_code input").val();
					if(!(/^1[3|4|5|7|8]\d{9}$/.test(phone))) {
						alert("手机号码格式错误!")
						return;
					}
					if(password.length < 6) {
						alert("密码不得低于6位!");
						return;
					}
					if(password == "") {
						alert("请输入密码!");
						return;
					}
					if(password != passwordAgin) {
						alert("两次输入的密码不一致!");
						return;
					}
					if(code == "") {
						alert("请输入验证码!");
						return;
					}
					if(!$("#reg .remember .checkbox").is(':checked')) {
						alert("请先阅读并同意平台相关政策!");
						return false;
					}
					var params = {
						username: phone,
						password: password,
						valiCode: code
					};
					ajax("/user/regist", params, function(json) {
						if(json.success) {
							alert("注册成功")
							loadReg(false);
							loadLogin(true, show_close);
						} else {
							M.toast(false, json.errorMsg);
						}
					});
				});
				$(".gologin").click(function() {
					loadReg(false);
					loadLogin(true);
				});
			}
			loadBackground(true);
			$("#reg").show(show_speed);
		} else {
			$("#reg").hide();
			loadBackground(false);
		}
	}

	//加载忘记密码方法
	function loadForgetPwd(a, show_close) {
		var reg = "";
		if(a) {
			var style = "style='display:block'";
			if(show_close != undefined) {
				style = "style='display:none'";
			}
			if($("#forgot").length == 0) {
				$("body").append("<div  style='display:none' id='forgot' style='display:block'><div>找回密码</div><div " + style + " class='f_close'><img src='../images/icons/icon_guangbi.png'></div><div class='f_phone'><input type='text' placeholder='手机号码'></div><div class='f_code'><div><input type='text' placeholder='验证码'></div><div class='get_code'>获取验证码</div></div><div class='f_pwd'><input type='password' placeholder='密码'></div><div class='f_pwdagin'><input type='password' placeholder='确认密码'></div><div class='f_btn'><span>确定</span></div></div>");
				placeholder_imitate();
				$("#forgot .f_close").click(function() {
					loadForgetPwd(false);
				});
				$("#forgot .get_code").click(function() {
					var r_phone = $("#forgot .f_phone>input").val();
					if(!(/^1[3|4|5|7|8]\d{9}$/.test(r_phone))) {
						alert("手机号码格式错误!");
						return;
					}
					$("#forgot .get_code").attr("phone", r_phone);
					sendCode($("#forgot .get_code"), 80, {
						A: "{color:'white'}",
						B: "{color:'white'}"
					});
				});
				$("#forgot .f_btn>span:nth-child(1)").click(function() {
					var phone = $("#forgot .f_phone>input").val();
					var password = $("#forgot .f_pwd >input").val();
					var passwordAgin = $("#forgot .f_pwdagin  input").val();
					var code = $("#forgot .f_code input").val();
					if(!(/^1[3|4|5|7|8]\d{9}$/.test(phone))) {
						alert("手机号码格式错误!");
						return;
					}
					if(password == "") {
						alert("请输入密码!");
						return;
					}
					if(password.length < 6) {
						alert("密码不得低于6位!");
						return;
					}
					if(password != passwordAgin) {
						alert("两次输入的密码不一致!");
						return;
					}
					if(code == "") {
						alert("请输入验证码!")
						return;
					}
					var params = {
						mobile: phone,
						password: password,
						smsCode: code
					};
					//修改密码
					ajax("user/reset", params, function(json) {
						if(json.success) {
							alert("密码修改成功!");
							loadForgetPwd(false);
							loadLogin(true, show_close);
						} else {
							M.toast(false, json.errorMsg);
						}
					});
				});
			}
			loadBackground(true);
			$("#forgot").show(show_speed);
		} else {
			$("#forgot").hide();
			loadBackground(false);
		}
	}

	loadOpt(true);
	//js获取项目根路径，如： http://localhost:6060/mainWeb
	function getRootPath() {
		var curWwwPath = window.document.location.href;
		var pathName = window.document.location.pathname;
		var pos = curWwwPath.indexOf(pathName);
		var localhostPaht = curWwwPath.substring(0, pos);
		var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
		projectName = projectName == "/page" ? "" : projectName;
		return(localhostPaht + projectName);
	}

	function getBasePath() {
		var curWwwPath = window.document.location.href;
		var pathName = window.document.location.pathname;
		var pos = curWwwPath.indexOf(pathName);
		var localhostPaht = curWwwPath.substring(0, pos);
		return(localhostPaht);
	}
	var homeurl = getRootPath();
	//var basepath = "http://192.168.1.38:8081";//getRootPath();
	var basepath = "http://192.168.1.32:8081";//getRootPath();
	//读取cookie的值
	function readCookie(name) {
		var cookieValue = "";
		var search = name + "=";
		if(document.cookie.length > 0) {
			offset = document.cookie.indexOf(search);
			if(offset != -1) {
				offset += search.length;
				end = document.cookie.indexOf(";", offset);
				if(end == -1)
					end = document.cookie.length;
				cookieValue = decodeURIComponent(document.cookie.substring(offset, end));
			}
		}
		return cookieValue;
	};
	/**
	 * 设置cookie
	 * @param {string} name  键名
	 * @param {string} value 键值
	 * @param {integer} days cookie周期
	 */
	function setCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}else{
			var expires = "";
		}
		document.cookie = name+"="+encodeURIComponent(value)+expires+"; path=/";
	}
	// 获取cookie
	function getCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
// 删除cookie
	function deleteCookie(name) {
		setCookie(name,"",-1);
	}

	//写入cookie
	function writeCookie(name, value, time) {
		var expire = "";
		if(time) {
			expire = new Date((new Date()).getTime() + time);
			expire = "; expires=" + expire.toGMTString();
		}
		document.cookie = name + "=" + encodeURIComponent(value) + "; path=/" + expire;
	};
	/*删除cookie的值*/
	function getCookie(name)//取cookies函数
	{
		var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
		if(arr != null) return unescape(arr[2]); return null;

	}


	function getParam(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		var r = window.location.search.substr(1).match(reg);
		if(r != null)
			return unescape(r[2]);
		return null;
	}
	//获取URL参数
	function getParamUrl(name,url) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		var r = url.substr(1).match(reg);
		if(r != null){
			return unescape(r[2]);
			return null;
		}
	}
	function myClick(obj, callback) {
		obj.unbind('click').click(function() {
			if($(this).attr('isClick') == null || $(this).attr('isClick') == "") {
				$(this).attr('isClick', "clicked");
				callback($(this));
			}
		});
	}

	function isWeiXin() {
		var ua = window.navigator.userAgent.toLowerCase();
		if(ua.match(/MicroMessenger/i) == 'micromessenger') {
			return true;
		} else {
			return false;
		}
	}

	function request(type, url, data, async, callback) {
		loadOpt(true);
		//		window.setTimeout(function() {
		loadOpt(false);
		try {
			var finalUrl = url;
			//去除字符串的所有的空格
			try {
				finalUrl = "";
				$(url.split("")).each(function() {
					finalUrl += this.replace(" ", "");
				});
			} catch(e) {}
			$.ajax({
				type: type,
				url: basepath + '/' + finalUrl,
				data: data,
				async: async,
				dataType: "json",
				success: function(json) {
					if(callback) {
						var finalJson = json;
						callback(finalJson);
					} else {}
				}
			});
		} catch(e) {}
		//				}, 10000);
	}

	function ajaxget(url, data, callback) {
		request('get', url, data, true, callback);
	}

	function ajax(url, data, callback) {
		request('post', url, data, true, callback);
	}

	function ajaxAsync(url, data, callback) {
		request('post', url, data, false, callback);
	}

	function checkAttention(openid, callback) {
		loadOpt(true);
		$.ajaxSettings.async = false; //设置getJson同步
		$.getJSON('http://pay.52pb.net/wxcore/getInfoByOpenId?appId=' + appId + '&openid=' + openid + '&callback=?', function(json) {
			loadOpt(false);
			if(json.subscribe == 1) {
				var paramStr = {
					type: 1,
					oauth_id: json.openid
				};
				ajaxAsync("user/login", {
					"paramStr": JSON.stringify(paramStr)
				}, function(json) {
					if(json.status != 1) {
						M.toast(false, json.msg, function() {
							location.href = homeurl + '/member/bind.html';
						});
					} else {
						writeCookie('xy_user', JSON.stringify({
							'userId': json.result.user_id,
							'phone': json.result.phone_number,
							'username': json.result.user_name,
							'nickName': json.result.user_name,
							'user_type': json.result.user_type
						}), 7 * 24 * 3600 * 1000);
						//						M.toast(true, "自动登录中...", function() {
						//							history.go(0);
						//							callback();
						//						});
					}
				})
				callback();
			} else {
				showQrcode(json.qrcode);
			}
		});
	}

	function showQrcode(image) {
		$('.qrcode_mask,.qrcode_box').remove();
		$('body').append('<div class="qrcode_mask" style="position:fixed;z-index:12;height:100%;width:100%;max-width:640px;background:black;opacity:0.8;top:0px"></div>');
		$('body').append('<div class="qrcode_box bounceIn" style="position:fixed;z-index:13;height:300px;width:280px;background:white;text-align:center;border-radius:4px">' +
			'<div style="color:#555555;text-align:center;font-size:14px;margin-top:20px">请先关注微信公众帐号</div>' +
			'<img src="' + image + '" style="height:220px;width:220px;margin-top:20px"/></div>');
		$('.qrcode_box').css('left', ($(window).width() - 280) / 2 + 'px');
		$('.qrcode_box').css('top', ($(window).height() - 300) / 2 + 'px');
	}
	var appId = "wx7f8f968809e50b3f";

	function checkLogin(status) {
		var object_user = new Object();
		object_user.state = 0; //登录状态 0:未登录 1:已登录
		object_user.info = {}; //用户信息
		if(readCookie("fp_user") != "") {
			try {
				var user_cookice = JSON.parse(readCookie("fp_user"));
				object_user.state = 1;
				//此处做查询用户信息并且返回
				object_user.info = user_cookice.info;
				var params = {
					username: user_cookice.loginInfo.username,
					password: user_cookice.loginInfo.password
				};
				ajaxAsync("/user/login", params, function(json) {
					if(!json.success) {
						M.toast(false, json.errorMsg);
						return false;
					} else {
						var userVO = new Object();
						userVO.info = json.models.userVO;
						userVO.loginInfo = params;
						writeCookie('fp_user', JSON.stringify(userVO), 7 * 24 * 3600 * 1000); //登录成功写cookice
						if(status) {
							if(userVO.info.typ == 0) {
								if(userVO.info.personVO.status == 1) {
									alert("您的资料还在审核中!");
									location.href = "../html/wait_review.html";
								} else if(userVO.info.personVO.status == 0) {
									alert("您还不是帮扶队员，请前往申请!");
									location.href = "../html/apply.html";
								}
							}
						}
					}
				});

			} catch(e) {}
		} else {}
		return object_user;
	}

	function getUserByOpenId(wxuser, callback) {
		loadOpt(true);
		ajaxAsync('/user/login', {
			"paramStr": JSON.stringify({
				'type': 1,
				'oauth_id': wxuser.openid
			})
		}, function(json) {
			loadOpt(false);
			if(json.status == 0) {
				M.toast(false, '请先绑定手机号码', function() {
					location.href = homeurl + '/member/bind.html';
				});
			} else {
				var user = {
					'openid': wxuser.openid,
					'sex': wxuser.sex,
					'personalId': json.result.user_id,
					'nickName': json.result.user_name,
					'phone': json.result.user_name,
					'user_type': json.result.user_type,
					'userId': json.result.user_id,
					'userName': json.result.user_name,
				};
				writeCookie('xy_user', JSON.stringify(user), 7 * 24 * 3600 * 1000);
				callback();
			}
		});
	}
	var islogin = false; //是否登录会员
	function sendCode(obj, time, css) {
		//obj 针对哪个按钮进行处理
		//time 每个手机号验证码间隔时间 /以秒为单位
		//css.A发送前的样式
		//css.B 发送后的样式
		checkTime();
		var timer = setInterval(TimerListener, 1000);
		if($(obj).attr("count_down") == "0" || $(obj).attr("count_down") == null) {
			send();
		}
		//倒计时事件
		function TimerListener() {
			var date1 = new Date(readCookie("phone" + $(obj).attr("phone")));
			var count_down = (date1.getTime() - new Date().getTime()) / 1000; //相差秒数}
			if(isNaN(parseInt(count_down))) {
				count_down = time;
			};
			$(obj).text("重新获取(" + parseInt(count_down) + ")");
			$(obj).attr("count_down", parseInt(count_down));
			if(parseInt(count_down) <= 0) {
				$(obj).text("获取验证码");
				$(obj).attr("count_down", 0);
				if(css != undefined) {
					$(obj).css(eval("(" + css.A + ")"));
				}
				clearInterval(timer);
				return false;
			}
		}
		//检查是否发送过验证码
		function checkTime() {
			var date1 = new Date(readCookie("phone" + $(obj).attr("phone")));
			var count_down = (date1.getTime() - new Date().getTime()) / 1000; //相差秒数}
			if(parseInt(count_down) > 0) {
				$(obj).attr("count_down", parseInt(count_down));
				$(obj).text("重新获取(" + parseInt(count_down) + ")");
				if(css != undefined) {
					$(obj).css(eval("(" + css.B + ")"));
				}
			}
		}
		//发送验证码
		function send() {
			var params = {
				"mobile": $(obj).attr("phone")
			};
			ajax("sms/send", params, function(json) {
				if(json.success) {
					alert("发送成功");
					var date = new Date();
					date.setTime(date.getTime() + parseInt(time) * 1000);
					writeCookie("phone" + $(obj).attr("phone"), date.toString(), date.toString());
					if(css != undefined) {
						$(obj).css(eval("(" + css.B + ")"));
					}
				}
			});

		}
	}
	//app交互
	function receiveTTerminalMessage(phone, userId) {

	}

	function createTree(objectTree){
		var tree="<div  id='tree'></div>";
		$(".tree").append(tree);
		$("#tree>div").empty();
		var li="";
		var index=getParam("index");
		$(objectTree).each(function(i) {
			if(index==i){
				li += "<li class='selected "+this.class+"' data-url='"+this.url+"'><img  src='"+this.hoverico+"' data-src='"+this.ico+"'/><span>"+this.name+"</span></li>";
			}else {
				li += "<li data-url='"+this.url+"' class='"+this.class+"'><img  src='"+this.ico+"' data-src='"+this.hoverico+"'/><span>"+this.name+"</span></li>";
			}
		});


		$("#tree").append("<ul>" + li + "</ul>");

		$("#tree li").hover(function(){
			var temp=$(this).find("img").attr("src");
			var tt=$(this).attr("class");
			if(tt=="" || tt=="showTip"){
				$(this).find("img").attr("src",$(this).find("img").attr("data-src"));
				$(this).find("img").attr("data-src",temp);
				$(this).addClass("tempClass");
			}

		},function(){
			var temp=$(this).find("img").attr("src");
			var tt=$(this).attr("class");
			if(tt.indexOf("selected")<0){
				$(this).find("img").attr("src",$(this).find("img").attr("data-src"));
				$(this).find("img").attr("data-src",temp);
				$(this).removeClass("tempClass");
			}


		})
		$("#tree li").click(function(){
			var cl=$(this).attr("class");
			if(cl.indexOf("showTip")>-1){
				$("body").append("<div class='sain' style='width: 100%;height: 100%;position:fixed;top:0;left:0;bottom:0;right:0;background-color:#000;opacity: 0.5;display: block'></div><div id='confirm' style='width: 460px;height: 300px;position: fixed;top: 30%;left: 37.5%;z-index: 21;' ><div  style='width: 100%;height: 60px;;text-align: center;background-color: #EFEFEF;font-size: 18px;line-height: 60px;'>提示</div><div style='width: 100%;height: 240px;background-color: #ffffff;' ><span style='font-size: 16px;color: #333333;line-height: 30px;padding: 39px 70px;display: block;'>本捐款用于未进入结对帮扶的城乡因病、因灾、因学返贫致贫的特困户，可通过网上申请或在当地民政部门申请。</span><div><span class='confirm-no' style='display: block;margin-top: 30px;width: 100px;height: 40px;border-radius: 5px;line-height: 40px;text-align: center;color: #333333;font-size: 20px;margin: 0 auto;background-color: rgb(239, 239, 239);cursor: pointer;float: left;margin-left: 20%'>取消</span><span class='confirm-OK' style='display: block;margin-top: 30px;width: 100px;height: 40px;border-radius: 5px;line-height: 40px;text-align: center;color: #ffffff;font-size: 20px;margin: 0 auto;background-color: #D30C1A;cursor: pointer;float:left;margin-left: 50px'>完成</span></div></div></div>");
				$(".sain").css("display","block");
				$("#confirm").css("display","block");
				$("#confirm>div").css("display","block");

				$(".confirm-OK").click(function(){
					$("#confirm").remove();
					$(".sain").remove();
					location.href='poor_people_edit.html?index=2';
				})
				$(".confirm-no").click(function(){
					$("#confirm").remove();
					$(".sain").remove();
				})
			}
			else{
				window.location.href=$(this).attr("data-url");
			}

		})
		var contentHeight = document.body.scrollHeight;//网页正文全文高度
		var winHeight = window.innerHeight;

		if(contentHeight<winHeight){
			contentHeight=winHeight;
		}
		$("#tree").css("height",(contentHeight-301)+"px");
	}
	var wx;
	var wx_share_init_success; //微信分享初始化成功
	initJssdk();

	function initJssdk() {
		if(isWeiXin()) {
			//微信浏览器分享初始化
			if(!wx) {
				seajs.use(['jweixin-1.0.0.js'], function(a) {
					$.ajaxSettings.async = false; //设置getJson同步
					$.getJSON('http://pay.52pb.net/wxcore/jssdk?appId=' + appId + '&callback=?&url=' + location.href, function(json) {
						if(json.status != 1 || json.params == null) {
							return;
						}
						wx = a;
						if(wx) {
							wx.config({
								debug: false,
								appId: json.params.appid,
								timestamp: json.params.timestamp,
								nonceStr: json.params.nonceStr,
								signature: json.params.signature,
								jsApiList: [
									'onMenuShareTimeline',
									'onMenuShareAppMessage',
									'onMenuShareQQ',
									'onMenuShareWeibo',
									'previewImage'
								]
							});
							wx.ready(function() {
								wx_share_init_success = true;
							});
							wx.error(function(res) {

							});
						}
					});
				});
			}
		}
	}
	var lazyImages;
	var exports = {
		//获取项目路径
		homeurl: homeurl,
		basepath: basepath,
		imageurl: 'http://139.224.12.88:8888/', //外网
		//imageurl: 'http://192.168.1.241:8888/', //241服务器
		getParam: getParam,
		getImageUrl: function getImageUrl(url) {
			if(url != null && url.indexOf('http') > -1) {
				return url;
			} else {
				return exports.imageurl + url;
			}
		},
		isWeiXin: isWeiXin,
		getWxUser: function() {
			var u = null;
			u = readCookie('xy_wxuser');
			if(u != null && u != '') {
				try {
					u = eval('(' + u + ')');
				} catch(e) {}
			}
			return u;
		},
		ajaxget: function(url, data, callback) {
			ajaxget(url, data, callback);
		},
		ajax: function(url, data, callback) {
			ajax(url, data, callback);
		},
		ajaxAsync: function(url, data, callback) {
			ajaxAsync(url, data, callback);
		},
		//接受终端传过来的信息
		receiveTTerminalMessage: receiveTTerminalMessage,
		sendCode: sendCode,
		//清除cookie中保存的验证码
		codeTimeOut: function(btn, type) {
			codeTimeOut(btn, type);
		},
		//写入cookie
		writeCookie: function(name, value, time) {
			writeCookie(name, value, time);
		},
		//读取cookie
		deleteCookie:function(name){
			deleteCookie(name);
		},
		readCookie: function(name) {
			return readCookie(name);
		},
		//初始化懒加载
		initLazy: function(images, scroll) {
			lazyImages = images;
			$(lazyImages).each(function(i) {
				var dom = $(this);
				if($(this).hasClass('repeat')) {
					var img = new Image();
					img.src = $(this).attr('data-src');
					img.onload = function() {
						dom.height(img.height / img.width * dom.parent().width());
						scroll.refresh();
					}
				}
				if(this.offsetTop <= (-scroll.y) + $('#wrapper').height()) {
					var img = new Image();
					img.src = $(this).attr('data-src');
					var imgDom = $(this).removeClass('lazyload');
					img.onload = function() {
						imgDom.attr('src', img.src).fadeIn(200);
					}
					scroll.refresh();
					lazyImages = $('.lazyload');
				}
			});
		},
		//图片懒加载
		lazyload: function(scroll) {
			$(lazyImages).each(function(i) {
				if(this.offsetTop <= (-scroll.y) + $('#wrapper').height()) {
					var imgDom = $(this).removeClass('lazyload');
					var img = new Image();
					img.src = $(this).attr('data-src');
					img.onload = function() {
						imgDom.attr('src', img.src).fadeIn(200);
					}
					scroll.refresh();
					lazyImages = $('.lazyload');
				}
			});
		},
		//返回顶部
		backTop: function(scroll, bottom) {
			bottom = bottom == null ? 70 : bottom;
			if((-scroll.y) > $('#wrapper').height() * 1.2) {
				if($('body').find('.backTop').length <= 0) {
					$('body').append('<img src="../images/icons/returnTop.png" class="backTop" style="position: fixed;width: 35px;z-index: 10;bottom: ' + bottom + 'px;right: 10px;background:white;border-radius:50%">');
					$('.backTop').fadeIn(200).click(function() {
						scroll.scrollTo(0, 0, 500);
					});
				}
			} else {
				$('body').find('.backTop').remove();
			}
		},
		//显示/隐藏加载框
		loadOpt: function(open) {
			loadOpt(open);
			//			if(open) {
			//				$('#loading_mask,#loading_dialog').css('display', 'block');
			//				$('#loading_icons').addClass('ball-spin-fade-loader');
			//			} else {
			//				$('#loading_mask,#loading_dialog').css('display', 'none');
			//				$('#loading_icons').removeClass('ball-spin-fade-loader');
			//			}
		},
		progress:function(inputList){
			progress(inputList);
		},
		//填充顶部导航
		fillHead: function() {
			var user = checkLogin();
			$("img").attr("alt", "加载中...");
			var menu = "";
			var up = "∨";
			up = "";
			ajaxAsync("news/queryByPid/0", {}, function(json) {
				if(json.success) {
					var nList = json.models.nList;
					for(var i = 0; i < nList.length; i++) {
						var classwto = "";
						$(nList[i].sonList).each(function() {
							classwto += "<p net='1' id='" + this.id + "' list='" + this.sonList.length + "'>" + this.name + "</p>"
						});
						menu += "<div list='" + nList[i].sonList.length + "' id='" + nList[i].id + "'><p>" + nList[i].name + "<span>" + up + "</span></p><div style='display:none' class='class_two'>" + classwto + "</div></div>";
					}
				}
			});
			var head =
			    "<div id='head'>" +
					"<div>" +
						//"<span style=''><img src='../images/icons/code.png' style='position: relative;top: 3px;right: 5px'/>客户端下载</span>" +
						"<div class='app' style='float: left;><span style=''><img src='../images/icons/code.png' style='position: relative;top: 3px;right: 5px'/>客户端下载</span><div class='app_download' style='background-color: #ffffff'><img src='../images/icons/code1.png' style='width: 150px;height: 150px'><p style='display: block;margin-top: -24px;text-align: center;'>android</p></div></div>" +
						"<span style='margin-left:45px' class='set_index'>设为首页</span>&nbsp;|&nbsp;" +
						"<span class='add_sc'>加入收藏</span>" +
						"</span>" +
						"<div class='head-login'>" +
							"<span style='margin-left:45px;color:#ADADAD;padding:2px 6px;border-radius:3px;margin-top:7px' class='top_login'>登录</span>" +
							"<span style='color:#ADADAD;padding:2px 6px;border-radius:3px;margin-top:7px' class='top_division'>|</span>" +
							"<span style='color:#ADADAD;padding:2px 6px;border-radius:3px;margin-top:7px' class='top_reg'>注册</span>" +
							"<span style='color:#ADADAD;padding:2px 6px;border-radius:3px;margin-top:7px' class='top_division'>|</span>" +
							"<span style='color:#ADADAD;padding:2px 6px;border-radius:3px;margin-top:7px' class='top_sq'>申请帮扶</span>" +
							"<span style='color:#ADADAD;padding:2px 6px;border-radius:3px;margin-top:7px' class='top_division'>|</span>" +
							"<span style='color:#ADADAD;padding:2px 6px;border-radius:3px;margin-top:7px' class='fplt'>扶贫论坛</span> " +
							"<span style='color:#e03d43;margin-left:30px'>咨询电话:" +
								"<span style='font-weight:bold'>0730-6688918</span>" +
							"</span> " +
						"</div>" +
					"</div>" +
				"</div>" +
				"<div id='title'>" +
					"<div class='title_content'>" +
						"<div class='logo'><img src='../images/icons/logo.png'></div>" +
						"<div id='top'>" +
							"<div>" +
								"<p>首页<span>∨</span></p>" +
								"<div class='class_two'></div>" +
							"</div>" + menu + "" +
						"</div>" +
						"<div class='search'>" +
							"<select name=''></select>" +
							"<input placeholder='输入搜索内容' type='text'> " +
							"<img class='search_icon' src='../images/temp/search.png'>" +
						"</div>" +
					"</div>" +
				"</div>";

			$("body").prepend(head);

			$(".app").mouseover(function(){
				$(".app_download").show("2000");

			})
			$(".app").mouseleave(function(){
				$(".app_download").hide("2000");
			})
			placeholder_imitate();
			$("body").append("<img id='backtop' src='../images/icons/backtop.png'>");
			var show = 1;
			$(window).scroll(function() {　　
				var scrollTop = $(this).scrollTop();　　
				var scrollHeight = $(document).height();　　
				var windowHeight = $(this).height();　　
				if(scrollTop == 0) {
					$("#backtop").hide(200);
					show = 1;
				} else {
					if(show == 1) {
						show = 0;
						$("#backtop").show(200);
					} else {
						$("#backtop").show();
					}
				}
			});
			$("#backtop").click(function() {
				location.href = "#head";
			});
			var dom_search = document.querySelector("#title select");
			var search_type_list = ["贫困户", "团队名称", "项目", "资讯"];//, '专项帮扶'
			$(search_type_list).each(function() {
				dom_search.options.add(new Option(this, this))
			});
			if(getParam("keyword") != null) {
				$("#title .search>input").val(getParam("keyword"));
			}
			if(getParam("search_type") != null) {
				$("#title select").val(getParam("search_type"));
			} else {
				$("#title select").val("贫困户");
			}
			$("#top>div").css("background-image", "none");
			var index = 0;
			if(getParam("index") != "") {
				index = getParam("index");
			}
			if(this_view() == "help_project.html" || this_view() == "project_details.html") {
				index = 1;
			}
			if(this_view() == "PingJiang_introduction.html") {
				index = 4;
			}
			var text = $("#top>div").eq(index).text();
			hover_event();
			if(user.state == 1) {

				/*$(".top_reg").remove();
				if(user.info != undefined) {
					if(user.info.typ == 0) {
						$(".top_login").text("帮扶申请");
					}
					if(user.info.personVO.status == 0) {
						$(".top_login").text("帮扶申请");
					}
					if((user.info.personVO.status == 1 || user.info.personVO.status == 2) && user.info.typ != 0) {
						$(".top_login").text("扶贫中心");
					}
				}*/
				$(".top_login").text(user.info.username);
				$(".top_reg").text("退出");
			}
			$(".top_login").click(function() {
				if($(this).text() == "登录") {
					loadLogin(true);
					return false;
				}
				/*if(user.info.personVO.status == 0) {
					location.href = "apply.html";
				}*/
				/*if(user.info.typ == 0 || user.info.typ == 4) {
					if(user.info.personVO.status == 1) {
						location.href = "wait_review.html";
					}
				}*/
				location.href = "user_index.html?index=0";

			});
			$("#head .set_index").click(function() {
				//设为主页
				alert("请手动设置!");
			});
			$("#head .add_sc").click(function() {
				//收藏
				alert("请使用快捷键Ctrl+D收藏本网站!");
			});
			$(".top_reg").click(function() {
				if($(this).text() == "注册") {
					loadReg(true);
				}else{
					/*调用退出接口*/
					ajax("/user/loginout", "", function(json) {
						if(!json.success) {
							M.toast(false, json.errorMsg);
							return false;
						} else {
							M.toast(false,"退出成功！");
							deleteCookie("fp_user");
							location.href = "index.html";
						}
					});
				}
			});
			$(".top_sq").click(function() {
				location.href = "apply.html";
			});
			$("#head .fplt").click(function() {
				location.href = "dynamic.html";
			});
			$("#title .logo").click(function() {
				location.href = "index.html";
			});
			$("#title .search_icon").click(function() {
				var keyword = ($("#title .search>input").val() + "");
				if(keyword == $("#title .search>input").attr("placeholder")) {
					keyword = "";
				}
				var search_type = $("#title select").val();
				if(search_type == "专项帮扶") {
					location.href = "help_special.html?keyword=" + escape(keyword) + "&search_type=" + escape(search_type);
				}

				if(search_type == "项目") {
					location.href = "help_project.html?keyword=" + escape(keyword) + "&search_type=" + escape(search_type);
				}
				if(search_type == "贫困户" || search_type == "团队名称" || search_type == "资讯") {
					location.href = "search_result.html?search_type=" + escape(search_type) + "&keyword=" + escape(keyword);
				}
			});
			$("#top>div").eq(1).click(function() {
				location.href = "search_result.html?search_type=" + escape(0) + "&keyword=" + escape('');
			});

			$("#top>div").click(function(e) {
				e.stopPropagation();
				var index = $(this).index();
				var id = $(this).attr("id");
				var list = $(this).attr("list");
				if(list > 0) {
					return false;
				}
				if(index > 0) {
					loadOpt(true);
					ajaxget("/news/newsByTid/" + id, {}, function(json) {
						loadOpt(false);
						if(json.success) {
							var news = json.models.newsDetailList;
							if(news.length == 1) {
								if(news[0].contentType == 1) {
									location.href = news[0].content;
									return false;
								} else {
									location.href = "Policy_details.html?id=" + news[0].id + "&index=" + getParam("index");
									return false;
								}
							} else {
								location.href = "policy_list.html?&id=" + id;
							}
						} else {
							M.toast(false, json.errorMsg);
						}
					});

				} else {
					if(index == 0) {
						location.href = "index.html?index=0";
					}

				}

			});
		},
		//填充底部菜单
		fillFooter: function() {
			var footer = "<div id='footer'><div></div></div>";
			$("body").append(footer);
			var lunbo = new Array();
			$("#footer>div").empty();
			ajaxAsync("/link/list", {}, function(json) {
				if(json.success) {
					var div = "";
					$(json.models.linkTyleList).each(function() {
						var li = "";
						$(this.linkList).each(function() {
							li += "<li url='" + this.url + "'>" + this.name + "</li>";
						});
						$("#footer>div").append("<div><ul>" + li + "</ul></div>");
					});
				}
				$("#footer>div").append("<div ><img src='../images/icons/code1.png' style='width: 100px;height: 100px;padding-top: 20px'><p style='color: #ffffff;text-align: center;'>android下载</p></div><div class='cr'>由专注精准安全的“深圳市星辰帷幄信息技术有限公司”提供技术支持</div>");
				$("#footer li").click(function() {
					window.open($(this).attr("url"));
				});
			});
		},
		fillTree:function(){
			var tree="<div  id='tree'></div>";
			$(".tree").append(tree);
			$("#tree>div").empty();
			var objectTree = new Object();
			objectTree = {}; //树节点
			var user=checkLogin();
			//console.log(user);
			var my_url="";
			if(user.info.typ==4){
				objectTree=[
					{"name":"基本资料","class":"","url":"../html/user_index.html?index=0","ico":"../images/icons/user-1.png","hoverico":"../images/icons/user-1-1.png"},
					{"name":"我的信息","class":"","url":"../html/wait_review.html?index=1","ico":"../images/icons/self-1.png","hoverico":"../images/icons/self-1-1.png"},
					{"name":"我的帮扶对象","class":"","url":"../html/user_help_class.html?index=2","ico":"../images/icons/myhelp-1.png","hoverico":"../images/icons/myhelp-1-1.png"},
					{"name":"修改密码","class":"","url":"../html/user_password.html?index=3","ico":"../images/icons/pwd-1.png","hoverico":"../images/icons/pwd-1-1.png"}];
				/*my_url="../html/wait_review.html?index=1";
				ajaxget("person/detailByUid/"+user.info.id, "", function(json) {
					if(json.success) {
						console.log(json);
						if(json.models.personVO.status==1){
							my_url="../html/personal_apply_edit.html?index=1";
							objectTree=[
								{"name":"基本资料","url":"../html/user_index.html?index=0","ico":"../images/icons/user-1.png","hoverico":"../images/icons/user-1-1.png"},
								{"name":"我的信息","url":my_url,"ico":"../images/icons/self-1.png","hoverico":"../images/icons/self-1-1.png"},
								{"name":"我的帮扶对象","url":"../html/user_help_class.html?index=2","ico":"../images/icons/myhelp-1.png","hoverico":"../images/icons/myhelp-1-1.png"},
								{"name":"修改密码","url":"../html/user_password.html?index=3","ico":"../images/icons/pwd-1.png","hoverico":"../images/icons/pwd-1-1.png"}];
							createTree(objectTree);
						}
						else{
							objectTree=[
								{"name":"基本资料","url":"../html/user_index.html?index=0","ico":"../images/icons/user-1.png","hoverico":"../images/icons/user-1-1.png"},
								{"name":"我的信息","url":my_url,"ico":"../images/icons/self-1.png","hoverico":"../images/icons/self-1-1.png"},
								{"name":"我的帮扶对象","url":"../html/user_help_class.html?index=2","ico":"../images/icons/myhelp-1.png","hoverico":"../images/icons/myhelp-1-1.png"},
								{"name":"修改密码","url":"../html/user_password.html?index=3","ico":"../images/icons/pwd-1.png","hoverico":"../images/icons/pwd-1-1.png"}];
							createTree(objectTree);
						}

					} else {
						M.toast(false, json.errorMsg);
					}
				});*/


			}
			else if(user.info.typ==3){
				objectTree=[
					{"name":"基本资料","class":"","url":"../html/user_index.html?index=0","ico":"../images/icons/user-1.png","hoverico":"../images/icons/user-1-1.png"},
					{"name":"我的信息","class":"","url":"../html/user_poor_people_info.html?index=1","ico":"../images/icons/self-1.png","hoverico":"../images/icons/self-1-1.png"},
					{"name":"被帮助记录","class":"","url":"../html/user_cover_help.html?index=2","ico":"../images/icons/help-1.png","hoverico":"../images/icons/help-1-1.png"},
					{"name":"修改密码","class":"","url":"../html/user_password.html?index=3","ico":"../images/icons/pwd-1.png","hoverico":"../images/icons/pwd-1-1.png"}];
				/*my_url="../html/user_poor_people_info.html?index=1";
				ajaxget("poverty/getByUser/"+user.info.id, "", function(json) {
					console.log(json.models.povertyObjVO.valiState);
					if(json.success) {
						if(json.models.povertyObjVO.valiState==2){
							my_url="../html/poor_people_edit.html?index=1";

							createTree(objectTree);

						}
						else{
							objectTree=[
								{"name":"基本资料","url":"../html/user_index.html?index=0","ico":"../images/icons/user-1.png","hoverico":"../images/icons/user-1-1.png"},
								{"name":"我的信息","url":my_url,"ico":"../images/icons/self-1.png","hoverico":"../images/icons/self-1-1.png"},
								{"name":"被帮助记录","url":"../html/user_cover_help.html?index=2","ico":"../images/icons/help-1.png","hoverico":"../images/icons/help-1-1.png"},
								{"name":"修改密码","url":"../html/user_password.html?index=3","ico":"../images/icons/pwd-1.png","hoverico":"../images/icons/pwd-1-1.png"}];
							createTree(objectTree);

						}
					} else {
						M.toast(false, json.errorMsg);
					}
				});*/

			}
			else{
				objectTree=[
					{"name":"基本资料","class":"","url":"../html/user_index.html?index=0","ico":"../images/icons/user-1.png","hoverico":"../images/icons/user-1-1.png"},
					{"name":"个人帮扶申请","class":"","url":"attention.html","ico":"../images/icons/self-1.png","hoverico":"../images/icons/self-1-1.png"},
					{"name":"申请成为贫困户","class":"showTip","ico":"../images/icons/user-1.png","hoverico":"../images/icons/user-1-1.png"},
					{"name":"修改密码","class":"","url":"../html/user_password.html?index=3","ico":"../images/icons/pwd-1.png","hoverico":"../images/icons/pwd-1-1.png"}];

			}
			createTree(objectTree);
		},
		/*弹窗显示*/
		tipShow:function(text,func){
			console.log(text);
			if(!text){
				text="尊敬的用户，您申请的资料已收到，我们将在7个工作日内进行审核，请您耐心等待！";
			}
			$("body").append("<div class='sain' style='width: 100%;height: 100%;position:fixed;top:0;left:0;bottom:0;right:0;background-color:#000;opacity: 0.5;display: block'></div><div id='confirm' style='width: 460px;height: 270px;position: fixed;top: 30%;left: 37.5%;z-index: 21;' ><div class='title' style='width: 100%;height: 60px;;text-align: center;background-color: #EFEFEF;font-size: 18px;line-height: 60px;'>提示</div><div style='width: 100%;height: 210px;background-color: #ffffff;' ><span style='font-size: 16px;color: #333333;line-height: 30px;padding: 39px 70px;display: block;'>"+text+"</span><span class='confirm-OK' style='display: block;margin-top: 30px;width: 256px;height: 40px;border-radius: 5px;line-height: 40px;text-align: center;color: #ffffff;font-size: 20px;margin: 0 auto;background-color: #D30C1A;cursor: pointer'>完成</span></div></div>");
			$(".sain").css("display","block");
			$("#confirm").css("display","block");
			$("#confirm>div").css("display","block");

			$(".confirm-OK").click(function(){
				$("#confirm").remove();
				$(".sain").remove();
				if(func){
					func();
				}
			})
		},
		tipPay:function(param,func){
			$("body").append("<script type='text/javascript' src='../js/jquery.js'></script><script type='text/javascript' src='../js/jquery.qrcode.min.js'></script><div class='sain' style='width: 100%;height: 100%;position:fixed;top:0;left:0;bottom:0;right:0;background-color:#000;opacity: 0.5'></div>" +
				"<div id='confirm' style='width: 620px;height: 540px;position: fixed;top: 10%;left: 30%;z-index: 21;' >" +
					"<div class='title' style='width: 100%;height: 60px;;text-align: center;background-color: #EFEFEF;font-size: 18px;line-height: 60px;'>提示</div>" +
					"<div style='width: 508px;height: 404px;background-color: #ffffff;padding: 38px 56px;' >" +
						"<div class='confirm-left'><div class='con-top'><span>微信支付：</span><span>100元</span></div><div class='con-center'></div><div class='con-bottom'></div></div><div class='confirm-right'></div>" +
					"</div>" +
				"</div>");
			$(".con-center").qrcode({
				width: 150, //宽度
				height:150, //高度
				text: param.url//任意内容
			});
			$(".confirm-OK").click(function(){
				$("#confirm").remove();
				$(".sain").remove();
				if(func){
					func();
				}
			})
		},
		//显示
		//根据对象或者
		getImg: function(objs) {
			return getImg(objs);
		},
		loadLogin: function(a, show_close) {
			loadLogin(a, show_close);
		},
		isIE: function() {
			return isIE();
		},
		browser: function() {
			return browser();
		},
		loadfail: loadfail,
		loadicon: loadicon,
		loadForgetPwd: function(a, show_close) {
			loadForgetPwd(a, show_close);
		},
		loadComplaint: function(a, object) {
			loadComplaint(a, object);
		},
		loadUnit_view: function(a, object) {
			loadUnit_view(a, object);
		},
		loadduty_view: function(a, object) {
			loadduty_view(a, object);
		},
		laodPoor_view: function(a, object) {
			laodPoor_view(a, object);
		},
		//从cookie获取用户信息
		getUser: function() {
			var u = null;
			u = readCookie('xy_user');
			if(u != null && u != '') {
				try {
					u = eval('(' + u + ')');
				} catch(e) {}
			}
			return u;
		},
		checkLogin: function(status) {
			return checkLogin(status);
		},
		paging_handle: function(page, method) {
			paging_handle(page, method)
		},
		//ie下模仿placeholder属性
		placeholder_imitate: function() {
			placeholder_imitate();
		},
		getNum: function(data) { //比较时间差
			return getNum(data);
		},
		payUrl: function() {
			return payUrl;
		},
		formPhone: function(phone) {
			return formPhone(phone);
		},
		//获取终端类型
		getTerminal: function(callback) {
			var Terminal = navigator.userAgent.toLowerCase();
			if(/iphone|ipad|ipod/.test(Terminal)) {
				callback("iphone");
			} else if(/android/.test(Terminal)) {
				callback("android");
			} else if(/windows/.test(Terminal)) {
				callback("windows");
			}
		},
		getbankIcon: function(value) {
			var img = "";
			switch(value) {
				case "中国农业银行":
					img = "../images/bank/ny.png";
					break;
				case "中国交通银行":
					img = "../images/bank/jt.png";
					break;
				case "中国建设银行":
					img = "../images/bank/js.png";
					break;
				case "中国邮政银行":
					img = "../images/bank/yz.png";
					break;
				case "中国广发银行":
					img = "../images/bank/gf.png";
					break;
				case "中国工商银行":
					img = "../images/bank/gs.png";
					break;
				case "中国民生银行":
					img = "../images/bank/ms.png";
					break;
				case "中国招商银行":
					img = "../images/bank/zs.png";
					break;
				case "福建兴业银行":
					img = "../images/bank/xy.png";
					break;
			}
			return img;
		},
		strSub: function(str, length) { //截取字符串
			if(str.length >= length) {
				str = str.substring(0, length - 3) + '...';
			}
			return str;
		},
		loadBackground: function(a) {
			loadBackground(a);
		},
		translate_time: function(str, reallyDo, replaceWith) {
			return translate_time(str, reallyDo, replaceWith);
		},
		initIscroll: function(IDSelector, height) { //初始化滚动控件
			$('#' + IDSelector).height($(window).height() - height);
			return new iScroll(IDSelector, {
				scrollbarClass: 'myScrollbar',
				hScroll: false
			});
		},
		initScrollImg: function(id, imgs, speed, showIndex) { //初始化图片滚动
			var showIndex = showIndex == null ? "" : "display:none";
			if(imgs == null) {
				imgs = new Array();
				imgs = [];
				var i = 0;
				var imgsStr = "";
				ajaxAsync("/index/list", {}, function(json) {
					if(json.success) {
						$(json.models.inList).each(function() {
							if(this.imageType == 1) {
								imgsStr += this.rotationImages + ",";
							}
							if(this.imageType == 2 && $("body").attr("class") == "index") {
								var rotationImages = loadfail;
								if(getImg(this.rotationImages).length > 0) {
									rotationImages = getImg(this.rotationImages)[0];
								}
								$(".adv >img").attr("src", rotationImages);
							}
							if(this.imageType == 3 && $("body").attr("class") == "index") {
								var rotationImages = loadfail;
								if(getImg(this.rotationImages).length > 0) {
									rotationImages = getImg(this.rotationImages)[0];
								}
								//$(".Notice_img>img").attr("src", rotationImages);
							}
						});
					}
					$(imgsStr.split(",")).each(function() {
						if(this != "") {
							imgs[i] = {
								"pic": this
							};
							i++;
						}
					});
				});
			}
			if(isIE() && browser() == "MSIE8.0") {
				var scroll = $('<div class="slides"><div class="slideInner"></div></div>');
				$("#" + id).append(scroll);
				var image = new Image();
				$(imgs).each(function(i) {
					//scroll.append('<img src="' + this.pic + '"/>');
					scroll.find(".slideInner").append('<a><img src="' + this.pic + '" /></a>');
					if(i == 0) {
						image.src = this.pic;
					}
				});
				setInterval(function() {
					if(image.width > 0 || image.height > 0) {
						$(".slides").height(image.height * ($("body").width() / image.width));
						$(".slideInner").height(image.height * ($("body").width() / image.width));
						$(".nav").height(image.height * ($("body").width() / image.width));
						$(".nav").width($("body").width());
						$(".nav a.next").css("top", image.height * ($("body").width() / image.width) / 2);
						$(".nav a.next").css("right", ($(".nav").width() - 1000) / 2);
						$(".nav a.prev").css("top", image.height * ($("body").width() / image.width) / 2);
						$(".nav a.prev").css("left", ($(".nav").width() - 1000) / 2);
					}
				}, 40);
				scroll.find(".slideInner a").css("background-size", "cover");
				scroll.append('<div class="nav" style="display: block;"><a class="prev" style="opacity: 0.5;" href="#"></a><a class="next" style="opacity: 0.2;" href="#"></a></div>');
				$(".slideInner").slide({
					slideContainer: $('.slideInner a'),
					effect: 'easeOutCirc',
					autoRunTime: 5000,
					slideSpeed: 1000,
					nav: true,
					autoRun: true,
					prevBtn: $('a.prev'),
					nextBtn: $('a.next')
				});
				return;
			} else {
				var scroll = $('<div class="scroll_bar" style="position:relative;"></div>')
				var list = $("<ul class='indexList' style='position: absolute;bottom: 16px;list-style:none;" + showIndex + "'></ul>");
				$("#" + id).append(scroll);
				$("#" + id).append(list).css('position', 'relative');
				$(imgs).each(function(i) {
					scroll.append('<img src="' + this.pic + '"/>');
					list.append('<li style="border:2px solid #7F7F84;background-color: white;height: 6px;width: 6px;border-radius: 50%;float: left;margin-left: 10px;opacity: 0.7;"></li>');
				});
				list.find('li').eq(0).css("background-color", "#41B888");
				list.find('li').eq(0).css("border", "2px solid #368D67");
				var width = $('body').width();
				scroll.find('img').css("width", width + "px");
				scroll.css('width', imgs.length * width + "px");
				var imgInterval;
				try {
					var myScroll = new iScroll(id, {
						snap: true,
						momentum: false,
						vScroll: false,
						hScroll: true,
						hScrollbar: false,
						eventPassthrough: false,
						onScrollEnd: function() {
							clearInterval(imgInterval);
							imgInterval = setInterval(a, speed);
							$('#' + id + ' .indexList li').css("background-color", "white");
							$('#' + id + ' .indexList li').css("border", "2px solid #7F7F84");
							$('#' + id + ' .indexList li').eq(this.currPageX).css("background-color", "#41B888");
							$('#' + id + ' .indexList li').eq(this.currPageX).css("border", "2px solid #368D67");
						}
					});

					function a() {
						myScroll.scrollToPage(myScroll.currPageX == imgs.length - 1 ? 0 : myScroll.currPageX + 1);
						$(".scroll_bar> img,.scroll_bar").unbind("mousedown");
						$(".scroll_bar> img,.scroll_bar").unbind("DOMMouseScroll");
						$(".scroll_bar> img,.scroll_bar").unbind("mousewheel");
					}
					clearInterval(imgInterval);
					imgInterval = setInterval(a, speed);
					list.css("right", "20%");
				} catch(e) {}

			}

		},
		wxShare: function(title, content, imgUrl, link, callback) {
			if(wx && wx_share_init_success) {
				var c = {
					title: title,
					desc: content,
					link: link,
					imgUrl: imgUrl,
					trigger: function(res) {
						if(typeof callback == 'function') {
							callback(0); //点击了分享按钮
						}
					},
					success: function(res) {
						if(typeof callback == 'function') {
							callback(1); //成功分享
						}
					},
					cancel: function(res) {
						if(typeof callback == 'function') {
							callback(-1); //取消分享
						}
					},
					fail: function(res) {
						if(typeof callback == 'function') {
							callback(-2); //分享出错
						}
					}
				};
				wx.onMenuShareTimeline(c); // 分享到朋友圈
				wx.onMenuShareAppMessage(c); // 分享给朋友
				wx.onMenuShareQQ(c); // 分享到QQ
				wx.onMenuShareQZone(c); // 分享到QQ空间
				wx.onMenuShareWeibo(c); // 分享到腾讯微博
			} else {
				setTimeout(function() {
					exports.wxShare(title, content, imgUrl, link, callback);
				}, 500)
			}
		},
		//微信图片预览方法
		wxpreviewImage: function(browserImgs, index) {
			wx.previewImage({
				current: browserImgs[index],
				urls: browserImgs
			});
		},
		getLocation: function(callback) { //获取当前坐标
			var options = {
				enableHighAccuracy: true,
				maximumAge: 1000
			}
			var position = {
				'success': false,
				'longitude': 0,
				'latitude': 0
			};
			var phone_type = getParam('phone');
			if(phone_type == 'android' || phone_type == 'ios') {
				var longitude = getParam('longitude');
				var latitude = getParam('latitude');
				var success = true;
				if(parseInt(longitude) == 0 && parseInt(latitude) == 0) {
					success = false;
					M.toast(false, "暂时获取不到位置信息");
				}
				var myLocation = {
					'longitude': longitude,
					'latitude': latitude,
					'success': success
				};
				callback(myLocation);
			} else {
				if(navigator.geolocation) {
					$('.messge-box').remove();
					navigator.geolocation.getCurrentPosition(function(position) {
						//地理位置获取成功
						position['success'] = true;
						position['longitude'] = position.coords.longitude; //经度
						position['latitude'] = position.coords.latitude; //纬度
						callback(position);
					}, function(error) {
						//地址位置获取失败
						switch(error.code) {
							case 1:
								M.toast(false, "位置服务被拒绝");
								break;
							case 2:
								/*	M.toast(false, "暂时获取不到位置信息");*/
								break;
							case 3:
								M.toast(false, "获取信息超时");
								break;
							case 4:
								M.toast(false, "未知错误");
								break;
						}
						callback(position);
					}, options);
				} else {
					$('.messge-box').remove();
					M.toast(false, '不支持获取地理位置！');
					callback(position);
				}
			}
		},
		getAddressByLocation: function(longitude, latitude, callback) { //通过坐标获取当前地址
			$.ajax({
				url: 'http://api.map.baidu.com/geocoder/v2/?ak=btsVVWf0TM1zUBEbzFz6QqWF&callback=renderReverse&location=' + latitude + ',' + longitude + '&output=json&pois=1',
				type: "get",
				dataType: "jsonp",
				jsonp: "callback",
				success: function(data) {
					var address = {
						country: data.result.addressComponent.country, //国家
						province: data.result.addressComponent.province, //省区
						city: data.result.addressComponent.city, //城市
						district: data.result.addressComponent.district, //区县
						street: data.result.addressComponent.street, //街道
						formatted_address: data.result.formatted_address, //完整地址
						longitude: longitude, //经度
						latitude: latitude //纬度
					};
					if(typeof callback == "function") {
						callback(address);
					}
				}
			});
		},
		getDistance: function(lat1, lng1, lat2, lng2) { //根据坐标获取两点距离
			var radLat1 = lat1 * Math.PI / 180.0;
			var radLat2 = lat2 * Math.PI / 180.0;
			var a = radLat1 - radLat2;
			var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
			var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
			s = s * 6378137.0 / 1000; //单位km
			s = Math.round(s * 10000) / 10000.0;
			return s.toFixed(2);
		},
		initMenu: function(id, reduceW, menus) { //加载X轴菜单
			$("#" + id + ">div").remove();
			var scroll = $('<div class="scroll_menu"></div>')
			$("#" + id).append(scroll);
			var width = 1;
			$(menus).each(function(i) {
				scroll.append('<div>' + this + '</div>');
				width += scroll.find('div').eq(i).width() + 10;
			});
			scroll.css('width', width + "px");
			$('#' + id).width($('body').width() - reduceW);
			var myScroll = new iScroll(id, {
				momentum: false,
				vScroll: false,
				hScroll: true,
				hScrollbar: false,
				bounce: true,
				momentum: true
			});
			myScroll.refresh();
		},
		//获得年月日      得到日期oTime  
		getMyDate: function(str, length) {
				var oDate = new Date(str),
					oYear = oDate.getFullYear(),
					oMonth = oDate.getMonth() + 1,
					oDay = oDate.getDate(),
					oHour = oDate.getHours(),
					oMin = oDate.getMinutes(),
					oSen = oDate.getSeconds(),
					oTime = oYear + '-' + getzf(oMonth) + '-' + getzf(oDay) + ' ' + getzf(oHour) + ':' + getzf(oMin) + ':' + getzf(oSen); //最后拼接时间  

				if(length != undefined) {
					return oTime.substring(0, length);
				} else {
					return oTime.substring(0, 11);
				}
			}

			,

		formatDate: function(strTime) { //时间距离计算
			var second = 1000;
			var minute = 60 * second; // 1分钟 
			var hour = 60 * minute; // 1小时 
			var day = 24 * hour; // 1天 
			var month = 31 * day; // 月 
			var year = 12 * month; // 年 
			var time = new Date(strTime.replace(/-/g, '/'));
			var diff = new Date().getTime() - time.getTime();
			var r = 0;
			if(diff > year) {
				return time.getFullYear() + "." + (time.getMonth() + 1) + "." + time.getDate();
			}
			if(diff > month) {
				return time.getFullYear() + "." + (time.getMonth() + 1) + "." + time.getDate();
			}
			if(diff > day) {
				r = (diff / day);
				return Math.floor(r) + "天前";
			}
			if(diff > hour) {
				r = (diff / hour);
				return Math.floor(r) + "小时前";
			}
			if(diff > minute) {
				r = (diff / minute);
				return Math.floor(r) + "分钟前";
			}
			if(diff > second && (diff / second) > 10) {
				r = (diff / second);
				return Math.floor(r) + "秒前";
			}
			return "刚刚";
		},
		elementMove: function(id) { //可拖动元素
			var element = document.getElementById(id);  
			var oW, oH;  
			element.addEventListener("touchstart", function(e) {  
				var touches = e.touches[0];   
				oW = touches.clientX - element.offsetLeft;   
				oH = touches.clientY - element.offsetTop;   
				document.addEventListener("touchmove", defaultEvent, false); //阻止页面的滑动默认事件
				  
			}, false);  
			element.addEventListener("touchmove", function(e) {   
				var touches = e.touches[0];   
				var oLeft = touches.clientX - oW;   
				var oTop = touches.clientY - oH;   
				if(oLeft < 0) {    
					oLeft = 0;   
				} else if(oLeft > document.documentElement.clientWidth - element.offsetWidth) {    
					oLeft = (document.documentElement.clientWidth - element.offsetWidth);   
				}   
				element.style.left = oLeft + "px";   
				element.style.top = oTop + "px"; 
			}, false);  
			element.addEventListener("touchend", function() {   
				document.removeEventListener("touchmove", defaultEvent, false);  
			}, false);  
			function defaultEvent(e) {   
				e.preventDefault();  
			}
		},
		getParamUrl: function(name,url){
			return getParamUrl(name,url);
		}
	};
	module.exports = exports;
});


function formPhone(phone) {
	var temp = phone;
	try {
		temp = "";
		temp = phone.substring(0, 2) + "********" + phone.substring(phone.length - 2);
	} catch(e) {}
	return temp;
}